#include "stdafx.h"
#include "GuiCharacterMgr.h"


GuiCharacterMgr::GuiCharacterMgr()
{
}


GuiCharacterMgr::~GuiCharacterMgr()
{
	if (m_root)
	{
		m_root->destroy();
		m_root = nullptr;
	}
}

void GuiCharacterMgr::InitWindow(char *layoutFile)
{
	m_root = CEGUI::WindowManager::getSingleton().loadLayoutFromFile(layoutFile);
	CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow(m_root);
	m_wnd_newCharacter1 = m_root->getChild("wnd_newCharacter1");
	CEGUI::Window *m_wnd_newCharacter2 = m_root->getChild("wnd_newCharacter2");
	CEGUI::Window *m_wnd_delete = m_root->getChild("wnd_delete");
	CEGUI::Window *m_wnd_delete_btn = m_wnd_delete->getChild("btn_delete");
	CEGUI::Window *m_wnd_ok = m_root->getChild("wnd_ok");
	CEGUI::Window *m_wnd_ok_btn = m_wnd_ok->getChild("btn_ok");
	m_wnd_newCharacter2->hide();

	m_wnd_ok_btn->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&GuiCharacterMgr::OnClicked_wnd_ok_btn, this));
}

void GuiCharacterMgr::OnClicked_wnd_ok_btn()
{
	if (m_cb_ok_btn)
	{
		m_cb_ok_btn();
	}
	else OutputDebugStringA("ok start game");
	
}